package com.dubbo.lian.cms.modules.app.service.impl;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.dubbo.lian.cms.modules.app.Checkcode;
import com.dubbo.lian.cms.modules.app.mq.Email;
import com.dubbo.lian.cms.modules.app.mq.queue.QueueMessageProducer;
import com.dubbo.lian.cms.modules.app.mapper.CheckcodeMapper;
import com.dubbo.lian.cms.modules.app.service.ICheckcodeService;
import com.dubbo.lian.common.util.BaseR;
import com.dubbo.lian.common.util.RandomUtils;
import com.dubbo.lian.common.util.ReturnTemplateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 /**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2017-02-27
 */
@Service
public class CheckcodeServiceImpl extends ServiceImpl<CheckcodeMapper, Checkcode> implements ICheckcodeService {
     private static Logger logger = LoggerFactory.getLogger(CheckcodeServiceImpl.class);
    @Autowired
    private QueueMessageProducer queueMessageProducer;
    @Override
    public BaseR getMailVerificationCode(String mail) {
        String verificationCode = RandomUtils.number(4);
        Email email = new Email();
        email.setAddress(mail);
        email.setContent(verificationCode);
        email.setTitle("验证码");
        queueMessageProducer.sendQueueMessage(email);
        return ReturnTemplateUtil.returnOfNull();
    }
 }
